package com.anderson.dashboardview.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;

import com.anderson.dashboardview.R;
import com.anderson.dashboardview.util.PxUtils;


/**
 * Created by anderson on 2016/6/5.
 */
public class DashboardViewAttr {
    private int mTextSize;      // 文本大小
    private String mText = "";  // 文本内容
    private int progressStrokeWidth;    // 进度条的宽
    private String unit;//单位
    private int textColor;      // 文本的颜色
    private int background;     // 背景

    private int startColor; // 渐变开始的颜色
    private int endColor;   // 渐变结束的颜色

    private float startNum;
    private float maxNum;
    private int padding;
    private int progressColor;
    private CharSequence[] tikeStrArray;
    private int tikeStrColor;
    private float tikeStrSize;
    private int circleColor;
    public DashboardViewAttr(Context context, AttributeSet attrs, int defStyleAttr) {
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DashboardView, defStyleAttr, 0);
        // 文本大小,默认24
        mTextSize = ta.getDimensionPixelSize(PxUtils.spToPx(R.styleable.DashboardView_android_textSize, context), 24);
        // 文本内容
        mText = ta.getString(R.styleable.DashboardView_android_text);
        // 进度条宽,默认24
        progressStrokeWidth = (int) ta.getDimension(R.styleable.DashboardView_progressStrokeWidth, 24);
        // 单位
        unit = ta.getString(R.styleable.DashboardView_unit);
        // 文本颜色 默认灰色#666666
        textColor = ta.getColor(R.styleable.DashboardView_textColor, context.getResources().getColor(R.color.textColor));
        // 背景颜色 默认透明？
        background = ta.getColor(R.styleable.DashboardView_backgroundColor, 0);
        // 渐变的开始颜色 默认透明？
        startColor = ta.getColor(R.styleable.DashboardView_startProgressColor, 0);
        // 渐变的结束颜色 默认透明？
        endColor = ta.getColor(R.styleable.DashboardView_endProgressColor, 0);

        startNum = ta.getInt(R.styleable.DashboardView_startNumber, 0);
        // 进度最大值 默认120
        maxNum = ta.getInt(R.styleable.DashboardView_maxNumber, 120);
        padding = PxUtils.dpToPx(ta.getInt(R.styleable.DashboardView_padding, 0), context);
        // 进度条颜色 默认浅蓝色 #ff87ceeb
        progressColor = ta.getColor(R.styleable.DashboardView_progressColor, context.getResources().getColor(R.color.skyblue));
        // 刻度？？？
        tikeStrArray = ta.getTextArray(R.styleable.DashboardView_tikeStrArray);
        // 刻度颜色
        tikeStrColor = ta.getColor(R.styleable.DashboardView_tikeStrColor, context.getResources().getColor(android.R.color.black));
        // 刻度文本大小
        tikeStrSize = ta.getDimension(R.styleable.DashboardView_tikeStrSize, 10);
        // 圆的颜色
        circleColor = ta.getColor(R.styleable.DashboardView_centerCircleColor, context.getResources().getColor(R.color.outsideBlue));
        ta.recycle();
    }

    public int getCircleColor() {
        return circleColor;
    }

    public int getProgressColor() {
        return progressColor;
    }

    public int getPadding() {
        return padding;
    }

    public float getStartNumber() {
        return startNum;
    }

    public float getMaxNumber() {
        return maxNum;
    }

    public int getEndColor() {
        return endColor;
    }

    public int getStartColor() {
        return startColor;
    }

    public int getBackground() {
        return background;
    }

    public int getmTextSize() {
        return mTextSize;
    }

    public String getmText() {
        return mText;
    }

    public int getProgressStrokeWidth() {
        return progressStrokeWidth;
    }

    public String getUnit() {
        return unit;
    }

    public int getTextColor() {
        return textColor;
    }

    public CharSequence[] getTikeStrArray() {
        return tikeStrArray;
    }

    public float getTikeStrSize() {
        return tikeStrSize;
    }

    public int getTikeStrColor() {
        return tikeStrColor;
    }
}
